/*
 * ProbabilityVector.java
 *
 * Created on 21 de Julho de 2011, 13:45
 *
 */

package intopo.partnerselection;

import cern.jet.random.engine.MersenneTwister;
import intopo.demonstrator.*;

/**
 *
 * @author <a href="mailto:mariano.pedro@gmail.com">Pedro Mariano</a>
 *
 * @version 1.0 21 de Julho de 2011
 */
public class ProbabilityVector
	extends AbstractProbabilityVector<AbstractProbabilityVector.Slot>
{
	
	/**
	 * Creates a new instance of ProbabilityVector
	 */
	public ProbabilityVector (int size, int maxProbability, MersenneTwister supply)
	{
		super (createArray (size), maxProbability, supply);
	}
	public ProbabilityVector (int[] probabilities)
	{
		super (createArray (probabilities));
	}
	static private AbstractProbabilityVector.Slot[] createArray (int size)
	{
		AbstractProbabilityVector.Slot[] result;
		result = new AbstractProbabilityVector.Slot [size];
		while (size > 0) {
			size--;
			result [size] = new AbstractProbabilityVector.Slot (0);
		}
		return result;
	}
	static private AbstractProbabilityVector.Slot[] createArray (int[] probabilities)
	{
		AbstractProbabilityVector.Slot[] result;
		result = new AbstractProbabilityVector.Slot [probabilities.length];
		int previous = 0;
		for (int i = 0; i < probabilities.length; i++) {
			previous += probabilities [i];
			result [i] = new AbstractProbabilityVector.Slot (previous);
		}
		return result;
	}
}

// Local Variables:
// mode: java
// mode: flyspell-prog
// ispell-local-dictionary: "british"
// End:
